package com.itxiuyixiu.homework.entity.dao;

import com.itxiuyixiu.homework.entity.model.Academy;
import com.itxiuyixiu.homework.entity.vo.AcademyVo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author 黄磊
 * @date 2020/3/5
 */
public interface AcademyDao extends JpaRepository<Academy, Integer> {
    boolean existsByAcademyName(String academyName);

    @Transactional(readOnly = true)
    @Query(value = "select * from Academy where id=?1" , nativeQuery = true)
    List<AcademyVo> findAllById(int id);

    @Transactional(readOnly = true)
    @Query(value = "select * from Academy where academyName=?1" , nativeQuery = true)
    List<AcademyVo> findAllByAcademyName(String academyName);

    @Transactional(readOnly = true)
    @Query(value = "select * from Academy" , nativeQuery = true)
    List<AcademyVo> findAllAcademy();
}
